
/* Generated by Interface Builder */

#import "InfoView.h"
#import "info.h"
#import <appkit/Application.h>
#import <appkit/nextstd.h>   // For MAX
#import <appkit/Text.h>
#import <appkit/Font.h>
#import <string.h>

@implementation InfoView

+ newFrame:(NXRect *)frm
{
  self = [super newFrame:frm];
  font = [Font newFont:"Times-Bold" 
	       size:MAX(floor(frm->size.width * 0.095), 6.0)
	       style:0
	       matrix:NX_IDENTITYMATRIX];  // We are using PSshow, not 
					   // the Text class...
  if (font == nil) font = [Text getDefaultFont];
  [self setClipping:NO];
  return (self);
}

- drawLogo
{
	float w,h;
		
	[self lockFocus];
	d += 0.025;
	if (d <=1.0) {
		PSdrawBeams(bounds.size.width,bounds.size.height,d);
	} else {
		[font set];
		PSsetgray(NX_WHITE);
		PSstringwidth ("Lighthouse Design, Ltd.", &w, &h);
	  	PSmoveto (bounds.size.width/2.0 - w/2.0, bounds.size.width / 30.0);
		PSshow("Lighthouse Design, Ltd.");
		drawnOnce = YES;
		drawing = NO;
		DPSRemoveTimedEntry(timedEntry);
	}
	[[self window] flushWindow];
	[self unlockFocus];
	return (self);
}

void infoTimerFunction(DPSTimedEntry te, double timenow, void *data)
{
	[(id)data drawLogo];
}


- windowDidBecomeKey:sender
{

	if (!(drawnOnce||drawing)) {
		PSInit();
		d = 0.0;
		timedEntry = DPSAddTimedEntry(0.01, &infoTimerFunction, self, NX_BASETHRESHOLD);
		drawing = YES;
	}
	return (self);
}

- drawSelf:(NXRect *)rects :(int)rectCount
{
  PSsetgray (NX_BLACK);
  NXRectFill (&bounds);
  return (self);
}

- windowWillClose:sender
{
	if (drawing)
		DPSRemoveTimedEntry(timedEntry);
	drawing = drawnOnce = NO;
	[self lockFocus];
	[self drawSelf:0 :0];
	[self unlockFocus];
	return self;
}


@end
